package exercise.no3;

import java.util.*;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-24
 */
public class Test {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("张三", 1800);
        map.put("李四", 2500);
        map.put("王五", 3900);
        System.out.println(map);

        map.put("张三", 2600);
        System.out.println(map);

        Set keyset = map.keySet();
        for (Object o : keyset) {
/*            if (o instanceof String) {
                String key = (String)o;
                int val = (int)map.get(key);
                map.put(key, val + 10);
            }*/
            map.put(o, (Integer)map.get(o) + 10);
        }
        System.out.println(map);

        Set entryset = map.entrySet();
        for (Object o : entryset) {
            Map.Entry entry = (Map.Entry)o;
            System.out.println((String)entry.getKey() + "-->" + entry.getValue());
        }

        Collection values = map.values();
        for (Object o : values) {
            System.out.println(o);
        }


    }
}
